﻿#ifndef CLOSEBUTTON_H
#define CLOSEBUTTON_H

#include <QPushButton>
#include <QString>
#include <QWidget>
//重写的按钮
class Button : public QPushButton
{
    Q_OBJECT
        Q_PROPERTY(int curIndex READ getcurIndex WRITE setcurIndex)
public:
    Button(QString FileName, int xnum = 1, QWidget* parent = 0,
        int ynum = 1, QString bkGrnd = NULL);
    Button(QVector<QString>& Vector, QWidget* parent = 0, QString bkGrnd = NULL);
    Button(QVector<QPixmap>* FileName, QWidget* parent = 0);
    //获取背景图片数组
    QVector<QPixmap>* getPixmaps(void) { return pixmatpVector; }
    //设置背景图片数组
    void setPixmaps(QVector<QPixmap>* vector);
    void setcurIndex(int index) { curIndex = index; update(); }
    int getcurIndex(void) { return curIndex; }

private:
    void setPixmapList(QVector<QString>& Vector);
    QPixmap* background=nullptr;

protected:
    QVector<QPixmap>* pixmatpVector=nullptr;
    int curIndex=0;

protected:
    //按钮背景，绘图事件
    virtual void paintEvent(QPaintEvent* event);
    //鼠标进入事件
    virtual void enterEvent(QEnterEvent* event);
    //鼠标离开事件
    virtual void leaveEvent(QEvent* event);
    //鼠标按下事件
    virtual void mousePressEvent(QMouseEvent* event);
    //鼠标松开事件
    virtual void mouseReleaseEvent(QMouseEvent* event);
    virtual  QSize sizeHint() const;

};

#endif // CLOSEBUTTON_H